package com.qf.controller;

import com.qf.pojo.BBClass;
import com.qf.service.BBClassService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
public class BBClassController {
    @Resource
    BBClassService bbClassService;
    @RequestMapping("/findAllBBClass")
    public List<BBClass> findAllBBClass(){

        return bbClassService.findAll();
    }

    @RequestMapping(value = "/addBBClass",method = RequestMethod.POST)
    public int addBBClass(@RequestBody BBClass bbClass){
        int add = bbClassService.add(bbClass);
        if (add>0){
            return 1;
        }else {
            return 0;
        }
    }
    @RequestMapping(value = "/updateBBClass",method = RequestMethod.POST)
    public int updateBBClass(@RequestBody BBClass bbClass){
        int update = bbClassService.update(bbClass);
        if (update>0){
            return 1;
        }else {
            return 0;
        }
    }

    @RequestMapping("/deleteBBClass/{bbid}")
    public int deleteBBClass(@PathVariable("bbid")int bbid) {
        int delete = bbClassService.delete(bbid);
        if (delete>0){
            return 1;
        }else {
            return 0;
        }
    }

    @RequestMapping("/findBBClassByBbid/{bbid}")
    public BBClass findBBClassByBbid(@PathVariable("bbid") int bbid){

        return bbClassService.findBBClassByBbid(bbid);
    }
}
